package com.eco.fanliapp.controller.app;


import com.eco.fanliapp.common.base.BaseController;
import com.eco.fanliapp.common.response.ServerResponse;
import com.eco.fanliapp.entity.AppUser;
import com.eco.fanliapp.service.ISyTljGoodsfreeService;
import com.eco.fanliapp.service.ISyTljGoodsfreeUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;


/**
 * <p>
 * 淘礼金免单商品用户对换表 前端控制器
 * </p>
 *
 * @author jobob
 * @since 2019-11-27
 */
@RestController
@RequestMapping("/app/tljGoodsfree")
public class SyTljGoodsfreeUserController extends BaseController {
    @Autowired
    private ISyTljGoodsfreeUserService iSyTljGoodsfreeUserService;

    @GetMapping(value = "/goodsfree/exchange")
    @ResponseBody
    public ServerResponse tljGoodsfreeExchange(Long itemId, String code) {

        AppUser u = getAppUser();
        if (u == null || u.getUserId() == null) {
            return ServerResponse.createBySuccessCodeMessage(301, "用户不存在");
        }

        return iSyTljGoodsfreeUserService.tljGoodsfreeExchange(u.getUserId(),itemId,code);
    }
}
